package com.wzn;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Test4 {
	public static void main(String args[]) {

		
	}

	public static String sendPost(String httpUrl, String httpArg) {
		 BufferedReader reader = null;
		    String result = null;
		    StringBuffer sbf = new StringBuffer();

		    try {
		        URL url = new URL(httpUrl);
			HttpURLConnection connection = (HttpURLConnection) url
		                .openConnection();
		        connection.setRequestMethod("Get");
		        connection.setRequestProperty("Content-Type",
		                        "application/x-www-form-urlencoded");
		        // 填入apikey到HTTP header
		        connection.setRequestProperty("apikey",  "您自己的apikey");
		        connection.setDoOutput(true);
		        connection.getOutputStream().write(httpArg.getBytes("UTF-8"));
		        connection.connect();
		        InputStream is = connection.getInputStream();
		        reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
		        String strRead = null;
		        while ((strRead = reader.readLine()) != null) {
		            sbf.append(strRead);
		            sbf.append("\r\n");
		        }
		        reader.close();
		        result = sbf.toString();
		    } catch (Exception e) {
		        e.printStackTrace();
		    }
		    return result;
	}

	private static String getA(String a) {
		// TODO Auto-generated method stub
		System.out.print(a);
		return a;
	}

	private static String getB(String b) {
		// TODO Auto-generated method stub
		System.out.print(b);
		System.exit(0);
		return b;
	}
}
